updating oE ensure_in_list
ensure_in_list
include math.e namespace math public function ensure_in_list(object item, sequence list, integer default = 1)
ensures that the item is in a list of values supplied by list.
Parameters:
- item : The object to test for.
- list : A sequence of elements that item should be a member of.
- default : an integer, the index of the list item to return if item is not found. Defaults to 1.
Returns:
An object, if item is not in the list, it returns the list item of index default, otherwise it returns item.
Comments:
If default is set to an invalid index, the first item on the list is returned instead when item is not on the list.
Example 1:
object valid_data = ensure_in_list(user_data, {100, 45, 2, 75, 121}) if not equal(valid_data, user_data) then errmsg("Invalid input supplied. Using %d instead.", valid_data) end if procA(valid_data)
Not Categorized, Please Help
|